#include <stdio.h>
#include <unistd.h>
#include <string.h>
enum
{
  Success=0,
  Div_zero,
  Mod_zero,
};
int exit_code = Success;
const char* CodeToErrString(int code){
  switch(code){
    case Success:
      return "Success";
    case Div_zero:
      return "Div_zero";
    case Mod_zero:
      return "Mod_zero";
    default:
      return "unknow error!";
  }

}
int fun(int x,int y){
  if(0==y){
    exit_code = Div_zero;
    return -1;
  }
  else{
    return x/y;
  }
}

int main(){
//  int errcode;
//  for(errcode=0;errcode<=255;errcode++){
//    printf("%d: %s\n",errcode,strerror(errcode));//打印错误码，错误信息表
//
//  }
//  printf("This is a return test!pid=%d ppid=%d\n",getpid(),getppid());
  int result=fun(10,100);
  printf("result: %d: [%s]\n",result,CodeToErrString(exit_code));
  result=fun(10,0);
  
  printf("result: %d: [%s]\n",result,CodeToErrString(exit_code));
  return exit_code;
//  printf("result: %d\n",result);
//  sleep(2);
//  return 0;//在这里改变返回值，就是改变退出码

}
